{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1edb093a",
   "metadata": {},
   "source": [
    "# week07 课本练习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e8584445",
   "metadata": {},
   "outputs": [],
   "source": [
    "phrase = \"Don't panic!\"\n",
    "plist = list(phrase)  # 把字符串转变为 list ： list(str)\n",
    "print(phrase)\n",
    "print(plist)\n",
    "# pop() 按index索引删除 如果不填则删除末位  对应记忆==>append()增加末位\n",
    "\n",
    "# 循环4次 进行四次plist的pop()方法操作，即删除4次末位\n",
    "for i in range(4):\n",
    "    plist.pop()\n",
    "print(plist)\n",
    "\n",
    "plist.pop(0)\n",
    "plist.remove(\"'\")\n",
    "print(plist)\n",
    "plist.extend([plist.pop(),plist.pop()])\n",
    "#                  a     ,      p\n",
    "print(plist)\n",
    "# 删除 位置3的 ‘ ’ 并且插入到  位置 2\n",
    "plist.insert(2,plist.pop(3))\n",
    "print(plist)\n",
    "#\n",
    "new_phrase = ''.join(plist) # 列表元素的合并\n",
    "print(\"plist=\",plist)\n",
    "print(\"new_phrase=\",new_phrase)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
